<!DOCTYPE html>
<html>
<head>
	<title>启动流程</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript">
        var path = window.document.location.href;
        var pathName = window.document.location.pathname;
        var hostPath = path.substring(0, path.indexOf(pathName));
        var projectName = pathName.substring(0, pathName.substr(1).indexOf("/") + 1);
        document.write('<scr' + 'ipt src="' + projectName + '/js/html/header.js"></scr'+'ipt>');
    </script>
</head>
<body>
	<form method="post" id="fm">
	<table  style="width: auto; height: auto" fitColumns="true">
		<tr>
	<td>流程key</td>
	<td><input id='procdef' name='procdef' class='easyui-validatebox' required='true'>&nbsp; <span style='color: red'>*</span></td>
	</tr>
	<tr>
		<td>业务编号</td>
		<td><input id='businessKey' name='businessKey' class='easyui-validatebox'>&nbsp; <span style='color: red'>*</span></td>
	</tr>
	<tr>
		<td>用户号</td>
		<td><input id='userId' name='userId' class='easyui-validatebox'>&nbsp; <span style='color: red'>*</span>
		</td>
	</tr>
	<tr>
		<td>下一节点处理人</td>
		<td><input id='handleUser' name='handleUser' class='easyui-validatebox'>&nbsp; <span style='color: red'>*</span>
		</td>
	</tr>
	</table>
	<div id="dg-buttons">
		<a href="javascript:startwork()" class="easyui-linkbutton" iconCls="icon-ok">提交</a>
		<a href="javascript:dlgClose()" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>
	</div>
	
	<script type="text/javascript">
		$(document).ready(function(){
			var reg = new RegExp("(^|&)" + 'processkey' + "=([^&]*)(&|$)");
		    var r = window.location.search.substr(1).match(reg);
			$('#procdef').val(decodeURI(r[2]));
		});
		
		function startwork() {
	    	$.messager.progress();
	    	$.ajax({
	    		type:"POST",
	    		url :projectName+"/workflow/process/start",
	    		data:JSON.stringify($("#fm input").serializeObject()),
	    		dataType:"json",
	    		contentType : "application/json;charset=utf-8",
	    		beforeSend : function() {
	            	var isValid = $("#fm").form("validate")
	            	if(!isValid){
	            		$.messager.progress("close");
	            		$.messager.alert("系统提示", "表单验证不通过！");
	            	}
	                return isValid;
	            },
	    		success : function(result) {
	            	$.messager.progress("close");
	                if (result.success) {
	    				$.messager.alert("系统提示", "提交成功！");
	                    resetFromValue();
	                    $("#win").dialog("close");
	                    $("#dg").datagrid("reload");
	                } else {
	                	if(!jQuery.isEmptyObject(result.message)){
	                		$.messager.alert("系统错误", result.message);
	                	}else{
	                		$.messager.alert("系统错误", result);
	                	}
	                    return;
	                }
	            },
	    		error:function(err, status){
	    			errorMsgAlert(err);
	    			$.messager.progress("close");
	    		}
	    	});
	    }
		    
	</script>
</body>
</html>

